<template>
<div>
  <el-radio-group v-model="condition" @change="changeCondi">
    <el-radio label="all" border>全部</el-radio>
    <el-radio label="transit" border>待中转</el-radio>
    <el-radio label="dispa" border>待配送</el-radio>
    <el-radio label="pick" border>待自提</el-radio>
  </el-radio-group>
  <el-table
    :data="cargos"
    border
    height="500"
    @row-dblclick="viewDetails"
    style="width: 100%; margin-top: 20px">
    <el-table-column prop="docId" label="单号"></el-table-column>
    <el-table-column prop="cargoName" label="名称"></el-table-column>
    <el-table-column prop="num" label="数量/件"></el-table-column>
    <el-table-column prop="weight" label="重量/kg"></el-table-column>
    <el-table-column prop="bulk" label="体积/m³"></el-table-column>
    <el-table-column prop="endSite" label="终点站"></el-table-column>
    <el-table-column prop="state" label="运单状态"></el-table-column>
  </el-table>
</div>
</template>

<script>

export default {
  data() {
    return {
      condition : 'all',
      cargos: JSON.parse(JSON.stringify(this.$store.state.modules.allSiteDocument.cargos))
    };
  },
  methods: {
    viewDetails(row) {
      this.$store.commit('clickTags',{name: '运单详情',path: "/home/documents/docDetails/"+row.docId})
      this.$store.commit('updActiveNav',this.$store.state.modules.navigation.navigation[0])
      this.$store.commit('updActiveTag',this.$store.state.modules.navigation.navigation[0].content[2])
      this.$router.push("/home/documents/docDetails/"+row.docId)
    },
    changeCondi(value) {
      switch(value) {
        case 'transit': {
          this.cargos.splice(0)
          for(let cargo of this.$store.state.modules.allSiteDocument.cargos) {
            if(cargo.endSite != this.$store.state.modules.loginAccount.account.sitetb.siteName) {
              this.cargos.push(cargo)
            }
          }
        }break;
        case 'dispa': {
          this.cargos.splice(0)
          for(let cargo of this.$store.state.modules.allSiteDocument.cargos) {
            if(cargo.state == "待配送") {
              this.cargos.push(cargo)
            }
          }
        }break;
        case 'pick': {
          this.cargos.splice(0)
          for(let cargo of this.$store.state.modules.allSiteDocument.cargos) {
            if(cargo.state == "待自提") {
              this.cargos.push(cargo)
            }
          }
        }break;
        default:{
          this.cargos.splice(0)
          for(let cargo of this.$store.state.modules.allSiteDocument.cargos) {
            this.cargos.push(cargo)
          }
        }
      }
    }
  }
}
</script>

<style scoped>
</style>
